home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / segal / list.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-23  |  3.9 KB  |  186 lines

  1. /*
  2.  *    list.c - for use with SEGAL
  3.  *
  4.  *    By Bryan Skene
  5.  *
  6.  */
  7.  
  8. #include "common.h"
  9.  
  10. /***************************************/
  11. recall_list()
  12. {
  13.     char *get_non_comment();
  14.  
  15.     FILE *fp;
  16.         char s[MAXPATHLEN], filename[MAXPATHLEN];
  17.      
  18.     strcpy(filename, (char *) xv_get(List_pop_list->text_l_fname,
  19.         PANEL_VALUE, NULL));
  20.  
  21.     if(strcmp(&filename[strlen(filename) - 4 - 1], ".list") != 0) {
  22.         /* append ".list" to filename */
  23.         strcat(filename, ".list");
  24.         xv_set(List_pop_list->text_l_fname,
  25.             PANEL_VALUE, filename,
  26.             NULL);
  27.     }
  28.  
  29.     if((fp = fopen(filename, "r")) == NULL) {
  30.         prgmerr(0, "Cannot find list");
  31.         return;
  32.     }
  33.  
  34.     /* image directory */
  35.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  36.         fclose(fp);
  37.         return;
  38.     }
  39.     xv_set(List_pop_list->text_i_dname,
  40.         PANEL_VALUE, s,
  41.         NULL);
  42.  
  43.     /* image filename */
  44.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  45.         fclose(fp);
  46.         return;
  47.     }
  48.     xv_set(List_pop_list->text_i_fname,
  49.         PANEL_VALUE, s,
  50.         NULL);
  51.  
  52.     /* clear out the mask directory and filenames first */
  53.     xv_set(List_pop_list->text_m_dname,
  54.         PANEL_VALUE, "<None>",
  55.         NULL);
  56.     xv_set(List_pop_list->text_m1_fname,
  57.         PANEL_VALUE, "<None>",
  58.         NULL);
  59.     xv_set(List_pop_list->text_m2_fname,
  60.         PANEL_VALUE, "<None>",
  61.         NULL);
  62.     xv_set(List_pop_list->text_m3_fname,
  63.         PANEL_VALUE, "<None>",
  64.         NULL);
  65.     xv_set(List_pop_list->text_m4_fname,
  66.         PANEL_VALUE, "<None>",
  67.         NULL);
  68.     xv_set(List_pop_list->text_m5_fname,
  69.         PANEL_VALUE, "<None>",
  70.         NULL);
  71.  
  72.     /* masks directory */
  73.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  74.         fclose(fp);
  75.         return;
  76.     }
  77.     xv_set(List_pop_list->text_m_dname,
  78.         PANEL_VALUE, s,
  79.         NULL);
  80.  
  81.     /* edit mask filename */
  82.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  83.         fclose(fp);
  84.         return;
  85.     }
  86.     xv_set(List_pop_list->text_m1_fname,
  87.         PANEL_VALUE, s,
  88.         NULL);
  89.  
  90.     /* other mask filenames */
  91.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  92.         fclose(fp);
  93.         return;
  94.     }
  95.     xv_set(List_pop_list->text_m2_fname,
  96.         PANEL_VALUE, s,
  97.         NULL);
  98.  
  99.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  100.         fclose(fp);
  101.         return;
  102.     }
  103.     xv_set(List_pop_list->text_m3_fname,
  104.         PANEL_VALUE, s,
  105.         NULL);
  106.  
  107.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  108.         fclose(fp);
  109.         return;
  110.     }
  111.     xv_set(List_pop_list->text_m4_fname,
  112.         PANEL_VALUE, s,
  113.         NULL);
  114.  
  115.     if(strcmp(strcpy(s, get_non_comment(fp)), "**EOF") == 0) {
  116.         fclose(fp);
  117.         return;
  118.     }
  119.     xv_set(List_pop_list->text_m5_fname,
  120.         PANEL_VALUE, s,
  121.         NULL);
  122.  
  123.     fclose(fp);
  124. }
  125.  
  126. /***************************************/
  127. store_list()
  128. {
  129.     FILE *fp;
  130.         char s[MAXPATHLEN], filename[MAXPATHLEN];
  131.      
  132.     strcpy(filename, (char *) xv_get(List_pop_list->text_l_fname,
  133.         PANEL_VALUE, NULL));
  134.     if((fp = fopen(filename, "w")) == NULL) {
  135.         prgmerr(0, "Cannot create list");
  136.         return;
  137.     }
  138.  
  139.     /* list description */
  140.     fprintf(fp, "**\n\tList for use with SEGAL 3D - by Bryan Skene\n**\n");
  141.  
  142.     fprintf(fp, "** Name: %s **\n", filename);
  143.  
  144.     fprintf(fp, "** Description: %s **\n",
  145.         (char *) xv_get(List_pop_list->text_description,
  146.             PANEL_VALUE, NULL));
  147.  
  148.     /* image directory */
  149.     fprintf(fp, "** Image Directory **\n%s\n",
  150.         (char *) xv_get(List_pop_list->text_i_dname,
  151.             PANEL_VALUE, NULL));
  152.  
  153.     /* image filename */
  154.     fprintf(fp, "** Image Filename **\n%s\n",
  155.         (char *) xv_get(List_pop_list->text_i_fname,
  156.             PANEL_VALUE, NULL));
  157.  
  158.     /* masks directory */
  159.     fprintf(fp, "** Directory of all Masks **\n%s\n",
  160.         (char *) xv_get(List_pop_list->text_m_dname,
  161.             PANEL_VALUE, NULL));
  162.  
  163.     /* edit mask */
  164.     fprintf(fp, "** Edit Mask **\n%s\n",
  165.         (char *) xv_get(List_pop_list->text_m1_fname,
  166.             PANEL_VALUE, NULL));
  167.  
  168.     /* other masks */
  169.     fprintf(fp, "** Other Masks (optional) **\n%s\n",
  170.         (char *) xv_get(List_pop_list->text_m2_fname,
  171.             PANEL_VALUE, NULL));
  172.  
  173.     fprintf(fp, "%s\n",
  174.         (char *) xv_get(List_pop_list->text_m3_fname,
  175.             PANEL_VALUE, NULL));
  176.  
  177.     fprintf(fp, "%s\n",
  178.         (char *) xv_get(List_pop_list->text_m4_fname,
  179.             PANEL_VALUE, NULL));
  180.  
  181.     fprintf(fp, "%s\n",
  182.         (char *) xv_get(List_pop_list->text_m5_fname,
  183.             PANEL_VALUE, NULL));
  184.     fclose(fp);
  185. }
  186.